#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>
constexpr int MaxN = 1e1 + 5;
constexpr int MaxM = 2e6 + 5;
int n;
bool answer[MaxM];
bool answerMore[MaxM];
std::vector<int> c;
std::vector<int> v[MaxN];
void print(bool *ptr = answer)
{
    bool enable = false;;
    for (int i = 2'000'000; i >= 0; i--)
    {
        if (ptr[i])
        {
            enable = true;
        }
        if (enable)
        {
            printf("%c", ptr[i] ? '1' : '0');
        }
    }
    printf("\n");
}
int main()
{
    freopen("mcmf.in", "r", stdin);
    freopen("mcmf.out", "w", stdout);
    scanf("%d", &n);
    if (n == 1)
    {
        int k;
        scanf("%d", &k);
        for (int i = 1; i <= k; i++)
        {
            int x;
            scanf("%d", &x);
            x--;
            answer[x] = true;
        }
        print();
        return 0;
    }
    if (n == 2)
    {
        for (int i = 1; i <= n; i++)
        {
            int k;
            scanf("%d", &k);
            for (int j = 1; j <= k; j++)
            {
                int x;
                scanf("%d", &x);
                x--;
                v[i].push_back(x);
            }
        }
        std::reverse(v[1].begin(), v[1].end());
        std::reverse(v[2].begin(), v[2].end());
        {
            for (const auto &val : v[1])
            {
                answer[val] = true;
            }
            std::map<int, bool> map;
            for (const auto &val : v[2])
            {
                if (!answer[val])
                {
                    map[val] = true;
                    answer[val] = true;
                    continue;
                }
                int j = val;
                for (;;)
                {
                    if (map[j])
                    {
                        answer[j] = false;
                    }
                    j++;
                    if (!answer[j])
                    {
                        break;
                    }
                }
                answer[j] = true;
                break;
            }
        }
        {
            for (const auto &val : v[2])
            {
                answerMore[val] = true;
            }
            std::map<int, bool> map;
            for (const auto &val : v[1])
            {
                if (!answerMore[val])
                {
                    map[val] = true;
                    answerMore[val] = true;
                    continue;
                }
                int j = val;
                for (;;)
                {
                    if (map[j])
                    {
                        answerMore[j] = false;
                    }
                    j++;
                    if (!answerMore[j])
                    {
                        break;
                    }
                }
                answerMore[j] = true;
                break;
            }
        }
        for (int i = 2'000'000; i >= 0; i--)
        {
            if (!answer[i] && answerMore[i])
            {
                print(answer);
                return 0;
            }
            else if (answer[i] && !answerMore[i])
            {
                print(answerMore);
                return 0;
            }
        }
        print(answer);
        return 0;
    }
    for (int i = 1; i <= n; i++)
    {
        int x, k;
        scanf("%d", &k);
        for (int j = 1; j <= k; j++)
        {
            scanf("%d", &x);
            x--;
        }
        c.push_back(x);
    }
    int current = 0;
    std::sort(c.begin(), c.end());
    for (const auto &val : c)
    {
        current = std::max(current, val);
        answer[current] = true;
        current++;
    }
    print();
    return 0;
}
